package yu.code.usercenter.exception;

import lombok.Data;
import yu.code.usercenter.common.ErrorCode;

/**
 *  自定义异常类
 */
@Data
public class BusinessException extends RuntimeException{
    private final int code;
    private final String description;
    private final ErrorCode errorCode;
    public BusinessException(ErrorCode errorCode) {
        this(errorCode, errorCode.getCode(), errorCode.getMessage(),errorCode.getDescription());
    }
    public BusinessException(ErrorCode errorCode,String description) {
        this(errorCode, errorCode.getCode(), "",description);
    }
    public BusinessException(ErrorCode errorCode,String message, String description) {
        this(errorCode, errorCode.getCode(), message,description);
    }
    public BusinessException(Integer code,String message, String description) {
        this(null, code, message,description);
    }
    public BusinessException(ErrorCode errorCode,Integer code,String message, String description) {
        super(message);
        this.errorCode = errorCode;
        this.code = code;
        this.description = description;
    }
}
